home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / ptv1n1.arc / KEYSPEED.C < prev    next >
C/C++ Source or Header  |  1990-06-08  |  1KB  |  57 lines

  1. /*
  2. KEYSPEED.C:     Set the typeamatic rate and delay on the keyboard
  3.  
  4. version:        11-02-89
  5. compiler:       QuickC 2.01
  6. uses:           stdtype.h, stdio.h, stdlib.h, bios.h
  7. module type:    .EXE (small model)
  8.  
  9. (C) Copyright 1989 Marty Franz
  10. */
  11.  
  12. #include <stdio.h>
  13. #include <stdlib.h>
  14. #include <bios.h>
  15.  
  16. #define KEYBOARD 0x16        /* keyboard interrupt */
  17. #define SET_RATES 0x0305     /* services to set rate and delay */
  18.  
  19. char *rates[32] = 
  20. {
  21.     "30.0", "26.7", "24.0", "21.8", "20.0", "18.5", "17.1",
  22.     "16.0", "15.0", "13.3", "12.0", "10.9", "10.0",  "9.2",
  23.     "8.6",  "8.0",  "7.5",  "6.7",  "6.0",  "5.5",  "5.0",
  24.     "4.6",  "4.3",  "4.0",  "3.7",  "3.3",  "3.0",  "2.7",
  25.     "2.5",  "2.3",  "2.1",  "2.0"
  26. }
  27. ;
  28.  
  29. char *delays[4] = 
  30. {
  31.     "250", "500", "750", "1000"
  32. }
  33. ;
  34.  
  35. void main(int argc, char *argv[], char *envp[])
  36. {
  37.     int temp;
  38.     union REGS inregs, outregs;
  39.  
  40.     if (argc != 3)
  41.     {
  42.         printf("Usage: %s <rate> <delay>\n", argv[0]);
  43.         puts("Sets keyboard typematic rate and delay.");
  44.         puts("Use 0 0 for fastest, 31 3 for slowest.");
  45.         exit(1);
  46.     }
  47.     inregs.x.ax = SET_RATES;
  48.     temp = atoi(argv[1]);
  49.     inregs.h.bl = (temp < 0x20) ? temp : 0x1f;
  50.     temp = atoi(argv[2]);
  51.     inregs.h.bh = (temp < 0x04) ? temp : 0x03;
  52.     printf("Rate: %s characters/second\nDelay: %s milliseconds\n",
  53.       rates[inregs.h.bl], delays[inregs.h.bh]);
  54.     int86(KEYBOARD, &inregs, &outregs);
  55.     exit(0);
  56. }
  57.